package cn.lanyi.controller;

import cn.lanyi.block.BlockGetUser;
import cn.lanyi.domain.User;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@RefreshScope
public class UserController {

    @GetMapping("/{id}")
    @SentinelResource(value="getUser",
            blockHandler = "blockGetUser",
            blockHandlerClass = BlockGetUser.class)
    public User getUser(@PathVariable Long id) {
        return new User(id, "名字","困死了");
    }

}
